import Vue from "vue";
import VueRouter from "vue-router";
import More from "../views/find/finddaily/More";
import Find from "../views/find/Find";

Vue.use(VueRouter);

// 解决路由冲突
const originalPush = VueRouter.prototype.push;

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

const routes = [
  { path: "/", redirect: "/find" },
  {
    path: "/login",
    component: () => import("../views/Login"),
    meta: {
      showFooter: false,
      showHeader: false,
    },
  },
  {
    path: "/find",
    name: "Find",
    component: Find,
    meta: {
      showFooter: true,
      showHeader: true,
      findShow: true,
      keepAlive: true,
      isUseCache: false,
    },
    children: [
      {
        path: "more",
        name: "More",
        component: More,
        meta: {
          showFooter: false,
          showHeader: false,
          findShow: false,
          keepAlive: true,
        },
      },
      {
        path: "daily",
        name: "Daily",
        component: () => import("../views/find/finddaily/Daily"),
        meta: {
          showFooter: false,
          showHeader: false,
          findShow: false,
          keepAlive: true,
        },
      },
    ],
  },
  {
    path: "/search",
    name: "Search",
    component: () => import("../views/find/Search"),
    meta: {
      showFooter: false,
      showHeader: true,
      searchPageShow: true,
    },
    children: [
      {
        path: "searchResult",
        component: () => import("../views/find/searchResult/index"),
        meta: {
          searchPageShow: false,
          showHeader: true,
        },
      },
    ],
  },

  {
    path: "/list",
    name: "List",
    component: () => import("../views/list/List"),
    meta: {
      showFooter: true,
      showHeader: false,
    },
  },
  {
    path: "/song/url/:id",
    name: "Songsdetail",
    component: () => import("../views/list/Songsdetail"),
    meta: {
      showFooter: false,
      showHeader: false,
    },
  },
  {
    path: "/me",
    name: "Me",
    component: () => import("../views/me/Me"),
    meta: {
      showFooter: true,
      showHeader: false,
    },
  },
  {
    path: "/bendi/:id",
    name: "Bendi",
    component: () => import("../views/me/song/Bendi"),
    meta: {
      searchPageShow: false,
      showHeader: true,
    },
  },
  {
    path: "/yunpan/:id",
    name: "Yunpan",
    component: () => import("../views/me/song/Yunpan"),
    meta: {
      searchPageShow: false,
      showHeader: true,
    },
  },
  {
    path: "/like/:id",
    name: "Like",
    component: () => import("../views/me/song/Like"),
    meta: {
      searchPageShow: false,
      showHeader: true,
    },
  },
  {
    path: "/gedan/:id",
    name: "Gedan",
    component: () => import("../views/me/song/Gedan"),
    meta: {
      searchPageShow: false,
      showHeader: true,
    },
  },
  {
    path: "/history/:id",
    name: "History",
    component: () => import("../views/me/song/History"),
    meta: {
      searchPageShow: false,
      showHeader: true,
    },
  },
  {
    path: "/shoucang/:id",
    name: "Shoucang",
    component: () => import("../views/me/song/Shoucang"),
    meta: {
      searchPageShow: false,
      showHeader: true,
    },
  },
  {
    path: "/ksong",
    name: "Ksong",
    component: () => import("../views/ksong/Ksong"),
    meta: {
      showFooter: true,
      showHeader: false,
    },
  },
  {
    path: "/playDetail/:id",
    name: "playDetail",
    component: () => import("../views/ksong/playDetail"),
    meta: {
      showFooter: false,
      showHeader: false,
    },
  },
  {
    path: "/cloud",
    name: "Cloud",
    redirect: "/cloud/CloudRecommend",
    component: () => import("../views/cloud/Cloud"),
    meta: {
      showFooter: true,
      showHeader: false,
    },
    children: [
      {
        path: "CloudFollow",
        component: () => import("../views/cloud/CloudFollow"),
        meta: {
          showFooter: true,
          showHeader: false,
        },
      },
      {
        path: "CloudRecommend",
        component: () => import("../views/cloud/CloudRecommend"),
        meta: {
          showFooter: true,
          showHeader: false,
        },
      },
    ],
  },
  {
    path: "/lyrics",
    name: "lyrics",
    component: () => import("../views/find/searchResult/lyric"),
    meta: {
    },
  },
];

const router = new VueRouter({
  routes,
  linkActiveClass: "active",
});

export default router;
